<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <ui:composition template="/resources/templates/default.xhtml">
        <ui:define name="title">Promotions</ui:define>
        <ui:define name="titlePage">Liste des promotions</ui:define>
        <ui:define name="content">
            <p:panel header="Promotion">   
                <h:panelGrid id="panelAjout" columns="1" cellpadding="5"> 
                    <h:form>
                        <p:commandButton id="effectsDialogButton" value="Ajouter une promotion" onclick="PF('dlg3').show();" type="button" />  
                    </h:form>
                </h:panelGrid>  

                <h:form id="formPromotions">
                    <p:dataTable id="listPromotions" value="#{administrationBean.promoModel}" var="prom" editable="true" 
                                 paginator="true" rows="10" selection="#{administrationBean.selectedPromotions}" >
                        <p:column headerText="Libellé" sortBy="libelle" filterBy="#{prom.libelle}">
                            <h:outputText value="#{prom.libelle}" />  
                        </p:column>
                        <p:column  style="width: 12%;text-align: center;" headerText="Suppression" selectionMode="multiple"  > 
                            <f:facet name="footer" >  
                                <p:commandButton value="Supprimer la sélection" oncomplete="PF('promosDeleteDialog').show()" 
                                                 update=":formDeletePromos" style="float:right; font-size: 10px;">  
                                    <p:confirm header="Confirmation" message="Etes vous sur de vouloir supprimer ces promotions?" icon="ui-icon-alert" />  
                                </p:commandButton>
                            </f:facet>  
                        </p:column>
                    </p:dataTable>
                </h:form>
            </p:panel>  
        </ui:define>
        <ui:define name="dialogs">
            <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">  
                <h:form>
                    <p:commandButton value="Oui" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>  
                    <p:commandButton value="Non" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>   
                </h:form>
            </p:confirmDialog>  
            
            <p:dialog id="dialog" header="Les promos suivantes on été supprimées"
                      widgetVar="promosDeleteDialog" resizable="false" showEffect="clip" hideEffect="puff" modal="true" closable="false">
                <h:form id="formDeletePromos">
                    <p:dataList  id="displayMulti" value="#{administrationBean.selectedPromotions}" var="selectedProm">  
                        <p:outputLabel value="Promo: #{selectedProm.libelle}" />
                                #{administrationBean.deletePromotions(selectedProm)}
                    </p:dataList> 

                    <h:panelGrid columns="2">
                        <p:commandButton value="OK" oncomplete="PF('promosDeleteDialog').hide()"
                                         update=":growl :formPromotions"/>
                    </h:panelGrid>
                </h:form>
            </p:dialog>
            
            <p:dialog id="dialogPromotion" header="Ajout d'une promotion" widgetVar="dlg3" modal="true" showEffect="clip" hideEffect="puff" height="350">   
                <h:form id="formulaire">   
                    <p:outputLabel value="Nom de la promotion correspondant au fichier CSV:" />
                    <p:inputText value="#{administrationBean.promotion.libelle}"  label="libelle" required="true"/>
                    <br /><br /> 
                    <p:commandButton value="Valider" actionListener="#{administrationBean.ajouterPromotion()}" update=":formPromotions:listPromotions :growl"   oncomplete="PF('dlg3').hide()" />             
                </h:form>
            </p:dialog> 
            
            
        </ui:define>
    </ui:composition>
</html>
